<template>
  <div>
    <el-badge :value="unreadMessageTotalNum" class="myItemBadge">
      <router-link to="/systemAdmin/systemMessageAdmin"><svg-icon :icon-class="'tiplingdang'"/></router-link>
    </el-badge>
  </div>
</template>

<script>
  import {queryCountUntreatedSystemMessage} from '@/api/system/systemMessage'

  import { mapState } from 'vuex'
  export default {
    name: 'NavbarMessageTip',
    data() {
      return {
        unreadMessageTotalNum: 0
      }
    },
    computed: {
      ...mapState({
        systemMessageNum: state => state.notify.systemMessageNum
      }),
    },
    watch: {
      systemMessageNum(value) {
        this.unreadMessageTotalNum =value
      },
    },
    created() {
      this.queryCountUntreatedSystemMessage()
    },
    methods: {
      /** 查询未读消息 */
      queryCountUntreatedSystemMessage() {
        queryCountUntreatedSystemMessage().then(res => {
            let num = res.data;
            this.unreadMessageTotalNum = num
            this.$store.commit('SET_SYSTEM_MESSAGE_NUM', num)
          }
        )
      }
    }
  }
</script>

<style scoped>
  /* 这个起作用 */
  .myItemBadge /deep/ .el-badge__content.is-fixed{
    top: 12px;
  }
</style>
